package com.niit.session13;

public class Girlfriend {
	private String name;
	private int age;

	public Girlfriend(String name, int age) {
		super();
		this.name = name;
		if(age<18 || age >50) {
			throw new AgeException("你这个年龄很刑，非常可拷！");
		}else {
			this.age = age;
			
		}
	}

	public Girlfriend() {
		super();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age){
		if(age<18 || age >50) {
//			throw关键字用于显式的抛出一个异常
//			如果抛出的是运行时异常，调用方可以不处理，如果抛出非运行时异常就必须处理
			throw new RuntimeException();
		}else {
			this.age = age;
		}
	}

}
